package com.maosy.demo.util

import android.app.Activity
import com.maosy.demo.MyApp
import com.maosy.demo.fragment.WebFragment

object PermissionUtil {

    fun checkLocationPerm(act: Activity): Boolean {
        val result = act.checkSelfPermission("android.permission.ACCESS_FINE_LOCATION")
        return if (result <= -1 || MyApp.location == null) {
            act.requestPermissions(
                arrayOf(
                    "android.permission.ACCESS_FINE_LOCATION",
                    "android.permission.ACCESS_COARSE_LOCATION"
                ),
                WebFragment.LOCATION_REQUEST_CODE
            )
            false
        } else {
            true
        }
    }
}
